//
//  GetProductListViewController.m
//  HAODE
//
//  Created by panquanReabam.com on 15/9/18.
//  Copyright (c) 2015年 reabam.com. All rights reserved.
//

#import "GetProductListViewController.h"
#import "addProductViewController.h"
#import "ProductDetailViewController.h"
#import "GetProductDetailViewController.h"
#import "getProuductListCell.h"
#import "RDVTabBarController.h"
#import "huiyuanDetailsViewController.h"

#import "sxview.h"
#import "saoyisaoViewController.h"
@interface GetProductListViewController ()<MBProgressHUDDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UITextFieldDelegate,UISearchBarDelegate,saoyisaoViewControllerDelegate>
@property (strong, nonatomic) NSString *areaValue;
@property (strong, nonatomic) NSString*cityValue;
@property (retain, nonatomic)NSString*dataTypeStr;
@property (retain, nonatomic)NSString*asc;
@property (retain, nonatomic)NSString*desc;
@property(nonatomic,retain)UIDatePicker* da;
@end

@implementation GetProductListViewController

{
    UISearchBar *search;
    HAODEsingleton* commdity;
    MJRefreshHeaderView* _header;
    MJRefreshFooterView* _footer;
    NSMutableArray*itemId;
    NSMutableArray*itemName;
    NSMutableArray*saleQty;
    NSMutableArray*salePrice;
    NSMutableArray*invQty;
    NSMutableArray*imageUrlFull;
   NSMutableArray*itemCode;
    NSMutableArray*itemType;
    NSMutableArray*maxPrice;
    NSMutableArray*hasSpec;
    NSMutableArray*minPrice;
    NSString *result;
    int pageNumber;
    MBProgressHUD *progressHud;
    UIView* backview1;
    UIScrollView*myscrollView;
    NSString* sous;
    int pageNumber1;
    int pageNumber2;
    NSString*meiyousuos;
    UIView*view3;
    UITextField*searchTextField;
    UITextField*telTextFied;
    UITextField*zbsTextFied;
    UITextField*zbsTextFied1;
    UITextField*gjzFied;
    UITextField*Salary1;
    UITextField*WorkExper1;
    UIView *view1;
    UIView *view2;
    UIButton*sat;
    UIButton*sat1;
    UIButton*sat2;
    UIView*myToolBar1;
    UIButton* sxBtn;
    UIButton*jiazai;
    UIButton*sxuan;
    float lastContentOffset;
    UIButton*jiantouNormal;
    BOOL saveAccount;
    BOOL saveAccount1;
    NSMutableArray* arrrs1;
    NSMutableArray* arrrs2;
    NSString*TotalCount;
    UIButton*shaixuanBtn;
    NSMutableArray*typeName;
    NSMutableArray*typeCode;
    NSMutableArray*isSingle;
    NSMutableArray*congzhicurrent;
    NSMutableArray*current;
    NSMutableArray*dataType;
    NSMutableArray *searchBeans;
    NSMutableArray*itemValue;
    NSMutableArray*items;
    UITextField*openTimeTextFied;
    UITextField*closeTimeTextFied;
    sxview*daogouView;
    UIView*view;
    UITableView *table_list;
    UIScrollView*mainScroll;
    NSMutableArray* arrrss;
    UILabel* noLabel;
    
    
    
    
    NSString*baioqianshuju;
    UITableView *biaoqiantable_list;
    NSMutableArray* biaoqianarrrss;
    NSMutableArray* biaoqianitemValue;
    NSMutableArray *selectitemNameArray;
    NSMutableArray *selectitemValueArray;
    NSMutableArray *isCustom;
    NSMutableArray *isRange;
    NSMutableArray *biaoqianxuanzhong;
    NSString* zhongzhisx;

}
@synthesize alt = alt;

-(void)BackAction:(UIButton *)sender{
    
    commdity.sat=@"";
    
//  [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:0] animated:YES];
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (void)viewDidDisappear:(BOOL)animated

{
    [super viewDidDisappear:animated];
    self.navigationController.delegate = nil;
    
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[self rdv_tabBarController] setTabBarHidden:YES];
    self.navigationController.navigationBarHidden = NO;
        self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 1)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:Color];
    
    UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.textAlignment=NSTextAlignmentLeft;
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    self.navigationController.delegate = self;
    
    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    UIView* view11=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth*555/750, 65/2)];
    view11.backgroundColor=zuiqianhuicolor;
    
    UIButton *sxBtn1 = [[UIButton alloc] initWithFrame:CGRectMake( 2, 3, 50/2, 50/2)];
    [sxBtn1 setImage:[UIImage imageNamed:@"sousuo"] forState:UIControlStateNormal];
    // [sxBtn addTarget:self action:@selector(sou) forControlEvents:UIControlEventTouchUpInside];
    [view11 addSubview:sxBtn1];

    searchTextField = [[UITextField alloc] initWithFrame:CGRectMake(sxBtn1.right,0, ScreenWidth*450/750,65/2)];
    [searchTextField setBorderStyle:   UITextBorderStyleNone]; //外框类型
    searchTextField.placeholder = @"扫描产品条码或输入产品编号"; //默认显示的字
    searchTextField.font = [UIFont systemFontOfSize: 14];
    searchTextField.tag=22;
    searchTextField.tintColor =tintCol;
    
    searchTextField.returnKeyType = UIReturnKeyDone;
    searchTextField.clearButtonMode = UITextFieldViewModeWhileEditing; //编辑时会出现个修改X
    searchTextField.delegate = self;
    //[searchTextField addTarget:self action:@selector(userNumberLimitTextLength:) forControlEvents:UIControlEventEditingChanged];
    [view11 addSubview:searchTextField];
    self.navigationItem.titleView = view11;
    [noLabel removeFromSuperview];
    
    UIButton*suobtn1=[[UIButton alloc]initWithFrame:CGRectMake(searchTextField.right-12, 2, 30,30)];
    [suobtn1 addTarget:self action:@selector(saoyisao:) forControlEvents:UIControlEventTouchUpInside];
    [suobtn1 setImage:[UIImage imageNamed:@"saoyisao-hui"] forState:UIControlStateNormal];
    [view11 addSubview:suobtn1];
   

    
    UIView* myToolBar=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, viewheight)];
    myToolBar.backgroundColor=jianpancolor;
    UIButton*  tubtnDone=[[UIButton alloc]initWithFrame:CGRectMake(logoX,logoY, logoheight, logowidth)];
    [tubtnDone setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [tubtnDone addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:tubtnDone];
    UIButton*btnDone111=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width - 55, 12, 40, 16)];
    [btnDone111 setTitle:@"确定" forState:UIControlStateNormal];
    [btnDone111 setTitleColor:jianpancolor1 forState:UIControlStateNormal];
    btnDone111 .titleLabel .font=[UIFont systemFontOfSize:daxiao];
    [btnDone111 addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:btnDone111];
    myToolBar.alpha=alp;
    UIButton* dabtn=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width-60, 0, 60, 40)];
    [dabtn addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:dabtn];
    searchTextField.inputAccessoryView = myToolBar;
    if ([commdity.sat isEqualToString:@"SCANSHOP"]) {
         searchTextField.text=commdity.noId;
    }
    [self add];
   commdity.userName=nil;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@""] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage =[[UIImage alloc] init];
    
    
}




- (void)secondViewController:(saoyisaoViewController *)secondViewController
                  updateText:(NSString *)text
{
    
    
 searchTextField.text=text;
   
}

-(void)saoyisao:(UIButton *)sender {
    
    commdity.sat=@"SCANSHOP";
    saoyisaoViewController*de = [[saoyisaoViewController alloc] init];
    de.delegate = self;
    [self.navigationController pushViewController:de animated:YES];
}
-(void)OnTapDone{
    
    [searchTextField resignFirstResponder];
    
    [self add];
    
    
}

- (void)viewDidLoad
{
    
    [super viewDidLoad];
  
   
    
    saveAccount1=NO;
    self.dataTypeStr=@"All";
    self.asc=@"";//按价格升序
    [self addFooter];
    [self addheader];
    UIButton* tianjiaBtn = [[UIButton alloc] initWithFrame:CGRectMake(30, 0.0,  60/2, 60/2)];
    [tianjiaBtn setImage:[UIImage imageNamed:@"tianjia"] forState:UIControlStateNormal];
    [tianjiaBtn addTarget:self action:@selector(addProduct:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* myBtnBtn = [[UIBarButtonItem alloc] initWithCustomView:tianjiaBtn];
    self.navigationItem.rightBarButtonItem = myBtnBtn;
    
    typeCode=[[NSMutableArray alloc]init];
    typeName=[[NSMutableArray alloc]init];
    items=[[NSMutableArray alloc]init];
    isSingle=[[NSMutableArray alloc]init];
    current=[[NSMutableArray alloc]init];
    congzhicurrent=[[NSMutableArray alloc]init];
    dataType=[[NSMutableArray alloc]init];
    
    
    
    selectitemNameArray=[[NSMutableArray alloc]init];
    selectitemValueArray=[[NSMutableArray alloc]init];
    isCustom=[[NSMutableArray alloc]init];
    isRange=[[NSMutableArray alloc]init];
    commdity=[HAODEsingleton shared];
    commdity.opentime=nil;
    commdity.closeTime=nil;
    commdity.anniusat=@"";
    commdity.content3=@"";
    commdity.gengxin=@"";
    arrrs1=[[NSMutableArray alloc]init];
    arrrs2=[[NSMutableArray alloc]init];
    
    _table.delegate=self;
    _table.dataSource=self;
    [self.view addSubview:_table];
    
    _table.separatorStyle=UITableViewCellSeparatorStyleNone;
  

    UIView*tableHeaderView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 40)];
    tableHeaderView.backgroundColor=zuiqianhuicolor;
    _table.tableHeaderView=tableHeaderView;
    
    sat=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth/4, 40)];
    [sat setTitle:@"最新" forState:UIControlStateNormal];
    [sat setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    sat.titleLabel.textAlignment=NSTextAlignmentLeft;
    sat.titleLabel.font=[UIFont systemFontOfSize:15];
    [sat addTarget:self action:@selector(sat:) forControlEvents:UIControlEventTouchUpInside];
    [tableHeaderView addSubview:sat];
    
    sat1=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/4, 0, ScreenWidth/4, 40)];
    [sat1 setTitle:@"销量" forState:UIControlStateNormal];
    [sat1 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    sat1.titleLabel.font=[UIFont systemFontOfSize:15];
    [sat1 addTarget:self action:@selector(sat1:) forControlEvents:UIControlEventTouchUpInside];
    sat1.titleLabel.textAlignment=NSTextAlignmentCenter;
    [tableHeaderView addSubview:sat1];
    
    sat2=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/4*2, 0, ScreenWidth/4, 40)];
    [sat2 setTitle:@"价格" forState:UIControlStateNormal];
    sat2.titleLabel.font=[UIFont systemFontOfSize:15];
    [sat2 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [sat2 addTarget:self action:@selector(sat2:) forControlEvents:UIControlEventTouchUpInside];
    sat2.titleLabel.textAlignment=NSTextAlignmentCenter;
    [tableHeaderView addSubview:sat2];
    
    jiantouNormal=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/4*2+68, 15, 10, 10)];
    [jiantouNormal setImage:[UIImage imageNamed:@"jiantou_normal"] forState:UIControlStateNormal];
    [jiantouNormal addTarget:self action:@selector(sat2:) forControlEvents:UIControlEventTouchUpInside];
    [tableHeaderView addSubview:jiantouNormal];
    
    
    
    shaixuanBtn=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth*590/750,  0, 70,40)];
    [shaixuanBtn.layer setCornerRadius:2.0];
    [shaixuanBtn.layer setBorderWidth:0];
    [shaixuanBtn.layer setMasksToBounds:YES];
    [shaixuanBtn addTarget:self action:@selector(sxuan:) forControlEvents:UIControlEventTouchUpInside];
    CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
    CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){153/255.0,153/255.0, 153/255.0, 1.0   });
    [shaixuanBtn.layer setBorderColor:colorref2];//边框颜色
    [shaixuanBtn setTitle:@"     筛选" forState:UIControlStateNormal];
    shaixuanBtn.titleLabel.font=[UIFont systemFontOfSize:15];
    [shaixuanBtn setTitleColor:shenhuicolor forState:UIControlStateNormal];
    shaixuanBtn.titleLabel.textAlignment=NSTextAlignmentRight;
    [tableHeaderView addSubview:shaixuanBtn];
    
    sxBtn = [[UIButton alloc] initWithFrame:CGRectMake(3,5, 30, 30)];
    [sxBtn setImage:[UIImage imageNamed:@"shaixuan"] forState:UIControlStateNormal];
    [sxBtn addTarget:self action:@selector(sxuan:) forControlEvents:UIControlEventTouchUpInside];
    [shaixuanBtn addSubview:sxBtn];
    
    
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    [param setValue:@"product" forKey:@"filterType"];
  //  NSLog(@"====%@",param);
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    [HttpRequest requestData:@"Common/AdvancedFilterList" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
//            NSLog(@"====－－－－－－－%@",severDataDict.dataDict);
            
            
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                
                NSMutableArray* arrr=[[NSMutableArray alloc]init];
                
                arrr=[severDataDict.dataDict objectForKey:@"DataLine"];
                
                for (NSDictionary* dicc in arrr )
                {
                    [typeName addObject:[dicc valueForKey:@"typeName"]];
                    [typeCode addObject:[dicc valueForKey:@"typeCode"]];
                    [items addObject:[dicc valueForKey:@"items"]];
                    [isSingle addObject:[dicc valueForKey:@"isSingle"]];
                    
                    [congzhicurrent addObject:[dicc valueForKey:@"current"]];
                    [current addObject:[dicc valueForKey:@"current"]];
                    [dataType addObject:[dicc valueForKey:@"dataType"]];
                    

                    
                }
                
                
                
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];

    
    
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    [searchTextField resignFirstResponder];
    [self add];
    
    return YES;
    
}

    


-(void)add{
    
    
    [noLabel removeFromSuperview];
   
//}
//- (void)hideAlertr
//{
//    



    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    [param setValue:@"1" forKey:@"pageIndex"];
    [param setValue:@"20" forKey:@"pageSize"];
    [param setValue:self.dataTypeStr forKey:@"dataType"];
    [param setValue:searchTextField.text forKey:@"keyword"];
    [param setValue:searchBeans forKey:@"searchBeans"];
    [param setValue:self.asc forKey:@"orderType"];
    
  //  NSLog(@"====%@",param);
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:20 view:self.view];
    
    
    [HttpRequest requestData:@"Product/GetProductList" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
            
            
            if (searchBeans.count>0) {
                
               UIImage *img=[UIImage imageNamed:@"shaixuan_hight"];
                UIImage *tinted = [img rt_tintedImageWithColor:luseColor];
                [shaixuanBtn setTitleColor:luseColor forState:UIControlStateNormal];
                [sxBtn setImage:tinted forState:UIControlStateNormal];                
                
            }else{
                [shaixuanBtn setTitleColor:shenhuicolor forState:UIControlStateNormal];
                [sxBtn setImage:[UIImage imageNamed:@"shaixuan"] forState:UIControlStateNormal];
            }

            NSLog(@"====%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                 pageNumber = 1;
                TotalCount=[severDataDict.dataDict objectForKey:@"TotalCount"];
                itemId= [[NSMutableArray alloc] init];
                itemName= [[NSMutableArray alloc] init];
                saleQty= [[NSMutableArray alloc] init];
                salePrice= [[NSMutableArray alloc] init];
                invQty= [[NSMutableArray alloc] init];
                imageUrlFull= [[NSMutableArray alloc] init];
                itemCode= [[NSMutableArray alloc] init];
                itemType= [[NSMutableArray alloc] init];
                minPrice= [[NSMutableArray alloc] init];
                maxPrice= [[NSMutableArray alloc] init];
                hasSpec= [[NSMutableArray alloc] init];
                if (TotalCount.intValue==0) {
                    noLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 17)];
                    noLabel.text=@"无数据";
                    noLabel.textColor=[UIColor blackColor];
                    noLabel.textAlignment=NSTextAlignmentCenter;
                    noLabel.center=self.view.center;
                    [self.view addSubview:noLabel];
                    [_table reloadData];
                }else{

                   
                NSMutableArray* arrr=[[NSMutableArray alloc]init];
                arrr=[severDataDict.dataDict objectForKey:@"DataLine"];
                for (NSDictionary* dicc in arrr )
                {
                    [itemId addObject:[dicc valueForKey:@"itemId"]];
                    [itemName addObject:[dicc valueForKey:@"itemName"]];
                    [saleQty addObject:[dicc valueForKey:@"saleQty"]];
                    [salePrice addObject:[dicc valueForKey:@"salePrice"]];
                    [invQty addObject:[dicc valueForKey:@"invQty"]];
                    [itemType addObject:[dicc valueForKey:@"itemType"]];
                    [itemCode addObject:[dicc valueForKey:@"itemCode"]];
                    [imageUrlFull addObject:[dicc valueForKey:@"imageUrlFull"]];
                   
                    [hasSpec addObject:[dicc valueForKey:@"hasSpec"]];
                    [maxPrice addObject:[dicc valueForKey:@"maxPrice"]];
                    [minPrice addObject:[dicc valueForKey:@"minPrice"]];
                    
                }
                    
                     [_table reloadData];
                }
    
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                // [Global showTextHud:requestResultStr view:self.view];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];

}


-(void)sat:(UIButton*)sender{
    [sat1 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [sat setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [sat2 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    self.dataTypeStr=@"All";
    self.asc=@"";
    [jiantouNormal setImage:[UIImage imageNamed:@"jiantou_normal"] forState:UIControlStateNormal];
    searchBeans=nil;
    [self add];
}
-(void)sat1:(UIButton*)sender{
    
//    self.dataTypeStr=@"All";
//    [self add];
    [sat setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [sat1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [sat2 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    
    
    saveAccount=!saveAccount;
    if (saveAccount) {
        
        self.dataTypeStr=@"All";
        self.asc=@"saleqty.asc";
        
        [self add];
//        [sat setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//        [sat1 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//        [sat2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//        
//        [jiantouNormal setImage:[UIImage imageNamed:@"shang_hight"] forState:UIControlStateNormal];
        
    }else{
        
        self.dataTypeStr=@"All";
        
        self.asc=@"saleqty.desc";
        [self add];
//        [sat setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//        [sat1 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//        [sat2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//        [jiantouNormal setImage:[UIImage imageNamed:@"xia_hight"] forState:UIControlStateNormal];
        
    }
    
  //
 //1鲁冰花 2雨蝶 3爱的代价 4涛声依旧 5广岛之恋 6画心 7小幸运  8天亮了  9他一定很爱你  10大中国  11一生有你  12故乡的云  13祝福  14同桌的你  15漂洋过海来看你 16母亲 17天之大  18同一首歌  19我不想说  20十年  21有个爱你的人不容易  22这辈子我们还可以在一起吗  23荷塘月色  24我的好兄弟  25怒放的生命 26北京北京  27春天里 28中国人 29我的中国心  30你是我的眼  31至少还有你  32那就这样吧  33生日礼物  34祈祷 35菊花台 36萍聚 37兄弟 38流着泪的你的眼 38浪花一朵朵 39外婆的澎湖湾 40爱的路上只有我和你  41童话  42丁香花 43红旗飘飘  44离别的车站  45水手 46星星点灯  47暖风  48蓝莲花 49执着 50时间去哪里了 51 2002年的第一场雪  52类似爱情  53当  54离别歌  55真心英雄 56我是一只小小鸟  57大海  58断点  59奔跑  60父亲 61爱江山更爱美人  62父子  63军中绿花  64我的老班长 65能不能叫你一生mylove 66庸人自挠 67星光依旧灿烂 68卓玛 69九百九十朵玫瑰 70别问我是谁 71
    
}


-(void)sat2:(UIButton*)sender{
    saveAccount=!saveAccount;
    if (saveAccount) {
        
        self.dataTypeStr=@"All";
        self.asc=@"saleprice.asc";
        
        [self add];
        [sat setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
            [sat1 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
            [sat2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        [jiantouNormal setImage:[UIImage imageNamed:@"shang_hight"] forState:UIControlStateNormal];
        
    }else{
        
        self.dataTypeStr=@"All";
        
       self.asc=@"saleprice.desc";
        [self add];
        [sat setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        [sat1 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        [sat2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [jiantouNormal setImage:[UIImage imageNamed:@"xia_hight"] forState:UIControlStateNormal];
        
    }
    
    
    
}

//


//下拉刷新
- (void)addheader
{
    
    //
    
    
    
    MJRefreshHeaderView* footer = [MJRefreshHeaderView header];
    footer.scrollView = _table;
    footer.beginRefreshingBlock = ^(MJRefreshBaseView* refreshView)
    {
        
//        self.sats=@"New";
        commdity.content3=@"";
        searchBeans=nil;
        self.dataTypeStr=@"New";
        [self add];
        
        [self performSelector:@selector(doneWithView:) withObject:refreshView afterDelay:3.0f];
       // NSLog(@"%@--->正在刷新", refreshView.class);
    };
}



//上拉刷新
- (void)addFooter
{
    
    
    MJRefreshFooterView* footer = [MJRefreshFooterView footer];
    footer.scrollView = _table;
    footer.beginRefreshingBlock = ^(MJRefreshBaseView* refreshView)
    {
        
        
        
        
        
      //  NSLog(@"---------%d",pageNumber);
       // NSLog(@"++++%d",TotalCount.intValue/5);
        
        
        if (TotalCount.intValue/20>=pageNumber) {
            pageNumber++;
            NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
            NSString* Token = [user objectForKey:@"tokenId"];
            if (Token ==nil) {
                Token=@"dd";
            }
            NSMutableDictionary *param = [NSMutableDictionary new];
            [param setValue:Token forKey:@"tokenId"];
            [param setValue:[NSString stringWithFormat:@"%d" ,pageNumber] forKey:@"pageIndex"];
            [param setValue:@"20" forKey:@"pageSize"];
            [param setValue:self.dataTypeStr forKey:@"dataType"];
            [param setValue:searchTextField.text forKey:@"keyword"];
            [param setValue:searchBeans forKey:@"searchBeans"];
            [param setValue:self.asc forKey:@"orderType"];
            
           // NSLog(@"====%@",param);
            [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:20 view:self.view];
            
            
            [HttpRequest requestData:@"Product/GetProductList" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
                if (isSuccess) {
                    
                 //   NSLog(@"====%@",severDataDict.dataDict);
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                        [Global hideProgressHUDInternal:self.view];
                        
                        NSMutableArray* arrr=[[NSMutableArray alloc]init];
                        arrr=[severDataDict.dataDict objectForKey:@"DataLine"];
                        for (NSDictionary* dicc in arrr )
                        {
                            [itemId addObject:[dicc valueForKey:@"itemId"]];
                            [itemName addObject:[dicc valueForKey:@"itemName"]];
                            [saleQty addObject:[dicc valueForKey:@"saleQty"]];
                            [salePrice addObject:[dicc valueForKey:@"salePrice"]];
                            [invQty addObject:[dicc valueForKey:@"invQty"]];
                            [itemType addObject:[dicc valueForKey:@"itemType"]];
                            [itemCode addObject:[dicc valueForKey:@"itemCode"]];
                            [imageUrlFull addObject:[dicc valueForKey:@"imageUrlFull"]];
                            [hasSpec addObject:[dicc valueForKey:@"hasSpec"]];
                            [maxPrice addObject:[dicc valueForKey:@"maxPrice"]];
                            [minPrice addObject:[dicc valueForKey:@"minPrice"]];

                            
                            
                        }
                        [_table reloadData];
                        
                        
                        
                        
                    }else{
                        [Global hideProgressHUDInternal:self.view];
                        NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                        // [Global showTextHud:requestResultStr view:self.view];
                        [Global showTextHudSub:requestResultStr view:self.view];
                    }
                    
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    
                    [Global showTextHudSub:@"连接失败" view:self.view];
                }
                
            }];
            
            
        }else{
            
            NSString *requestResultStr=@"没有更多数据了！";
            // [Global showTextHud:requestResultStr view:self.view];
            [Global showTextHudSub:requestResultStr view:self.view];
            
            
        }
        
        
        
        
        
        
        [self performSelector:@selector(doneWithView:) withObject:refreshView afterDelay:3.0f];
      //  NSLog(@"%@--->正在刷新", refreshView.class);
    };
}
- (void)doneWithView:(MJRefreshBaseView *)refreshView
{
    [_table reloadData];
    [refreshView endRefreshing];
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    if (tableView == table_list) {
        return [typeCode count];
    }
    
    if (tableView == biaoqiantable_list) {
        return [biaoqianarrrss count];
    }
    
    return [itemId count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    getProuductListCell* cell = (getProuductListCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        NSArray* nib = [[NSBundle mainBundle] loadNibNamed:@"getProuductListCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    }
    UIButton*jiantou = [[UIButton alloc]init];
    jiantou.frame = CGRectMake(0,0, 8, 13);
    [jiantou setImage:[UIImage imageNamed:@"xiangzuo-.png"] forState:UIControlStateNormal];
    
    //    cell.accessoryView = jiantou;
    
    
if (tableView == _table) {
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    
    
    [cell.imageUrlFull.layer setCornerRadius:6.0];
    [cell.imageUrlFull.layer setBorderWidth:0.3];
    [cell.imageUrlFull.layer setMasksToBounds:YES];
    CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
    CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){ 0, 0, 0, 0.3 });
    [cell.imageUrlFull.layer setBorderColor:colorref2];//边框颜色
//   [cell.image setImageWithURL:[NSURL URLWithString:[ImageUrl objectAtIndex:indexPath.row]]];
    [cell.imageUrlFull setImageWithURL:[NSURL URLWithString:[imageUrlFull objectAtIndex:indexPath.row]]placeholderImage:[UIImage imageNamed:@""]];
    UIButton* button=[[UIButton alloc]init];
    button.frame=cell.imageUrlFull.frame;
    [button.layer setCornerRadius:6.0];
    [button.layer setBorderWidth:0.3];
    [button.layer setMasksToBounds:YES];
    CGColorSpaceRef colorSpace21 = CGColorSpaceCreateDeviceRGB();
    CGColorRef colorref21 = CGColorCreate(colorSpace21,(CGFloat[]){ 0, 0, 0, 0.3 });
    [button.layer setBorderColor:colorref21];//边框颜色
    [button setImageWithURL:[NSURL URLWithString:[imageUrlFull objectAtIndex:indexPath.row]] placeholderImage:[UIImage imageNamed:@""]];
    [cell.contentView addSubview:button];



    cell.itemName.text =[NSString stringWithFormat:@"%@ %@",[itemCode objectAtIndex:indexPath.row], [itemName objectAtIndex:indexPath.row]];
    cell.itemName.font=[UIFont systemFontOfSize:titleNamefot];
    cell.itemName.textColor=[UIColor blackColor];
    cell.itemName.numberOfLines=0;

    NSString *s = [NSString stringWithFormat:@"%@", @"库存"];
    cell.saleQty.text =[NSString stringWithFormat:@"%@ %.f 件",s, [[invQty objectAtIndex:indexPath.row]doubleValue ]];
    cell.saleQty.font=[UIFont systemFontOfSize:contenfot];
    cell.saleQty.textColor=shenhuicolor;
    
    
    if ([[NSString stringWithFormat:@"%@",[hasSpec objectAtIndex:indexPath.row]]isEqualToString:@"N"]) {
      
        NSString*GoldPrice=[NSString stringWithFormat:@"%@",[salePrice objectAtIndex:indexPath.row]];
        NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
        [numberFormatter setPositiveFormat:@"###,##0;"];
        NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
        
        
        cell.salePrice.text =[NSString stringWithFormat:@"￥%@",  formattedNumberString];
        cell.salePrice.font=[UIFont systemFontOfSize:18];
        cell.salePrice.textColor=hongsecolor;
        
        NSMutableAttributedString *AttributedStr2 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"￥%@",formattedNumberString]];
        [AttributedStr2 addAttribute:NSFontAttributeName
         
                               value:[UIFont systemFontOfSize:14.0]
         
                               range:NSMakeRange(0, 1)];
        
        [AttributedStr2 addAttribute:NSForegroundColorAttributeName
         
                               value:hongsecolor
         
                               range:NSMakeRange(0, 1)];
        
        
        cell.salePrice.attributedText = AttributedStr2;


    }else{
    
    
        NSString*GoldPrice1=[NSString stringWithFormat:@"%@",[minPrice objectAtIndex:indexPath.row]];
        NSNumberFormatter *numberFormatter1 = [[NSNumberFormatter alloc] init];
        [numberFormatter1 setPositiveFormat:@"###,##0;"];
        NSString *formattedNumberString1 = [numberFormatter1 stringFromNumber:[NSNumber numberWithDouble:GoldPrice1.floatValue]];
        
        NSString*GoldPrice=[NSString stringWithFormat:@"%@",[maxPrice objectAtIndex:indexPath.row]];
        NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
        [numberFormatter setPositiveFormat:@"###,##0;"];
        NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
        
        
        
        if (GoldPrice1.intValue==GoldPrice.intValue) {
            cell.salePrice.font=[UIFont systemFontOfSize:18];
            cell.salePrice.textColor=hongsecolor;

             cell.salePrice.text =[NSString stringWithFormat:@"￥%@",formattedNumberString1];
            NSMutableAttributedString *AttributedStr23 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"￥%@",formattedNumberString1]];
            [AttributedStr23 addAttribute:NSFontAttributeName
             
                                   value:[UIFont systemFontOfSize:14.0]
             
                                   range:NSMakeRange(0, 1)];
            
            [AttributedStr23 addAttribute:NSForegroundColorAttributeName
             
                                   value:hongsecolor
             
                                   range:NSMakeRange(0, 1)];
            
            
            cell.salePrice.attributedText = AttributedStr23;
           

        }else{
            cell.salePrice.font=[UIFont systemFontOfSize:18];
            cell.salePrice.textColor=hongsecolor;

            cell.salePrice.text =[NSString stringWithFormat:@"￥%@～%@",formattedNumberString1,  formattedNumberString];
            NSMutableAttributedString *AttributedStr24 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"￥%@～%@",formattedNumberString1,  formattedNumberString]];
            [AttributedStr24 addAttribute:NSFontAttributeName
             
                                   value:[UIFont systemFontOfSize:14.0]
             
                                   range:NSMakeRange(0, 1)];
            
            [AttributedStr24 addAttribute:NSForegroundColorAttributeName
             
                                   value:hongsecolor
             
             
                                   range:NSMakeRange(0, 1)];
            
            
            cell.salePrice.attributedText = AttributedStr24;
         

        }
        
           }
    
    //  cell.salePrice.frame=CGRectMake(400*ScreenWidth/750, ScreenHeight*170/1334, 400*ScreenWidth/750,18);

    if (itemName.count !=indexPath.row+1) {
        UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(15, 120-0.35, ScreenWidth-30, 0.35)];
        lineLabel1.backgroundColor=qianhuicolor;
        [cell.contentView addSubview:lineLabel1];
        
    }
    
    if (itemName.count ==indexPath.row+1) {
        UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(0, 120-0.35, ScreenWidth, 0.35)];
        lineLabel1.backgroundColor=qianhuicolor;
        [cell.contentView addSubview:lineLabel1];
    }
    }
    cell.detailTextLabel.font=[UIFont systemFontOfSize:15];
    cell.textLabel.font=[UIFont systemFontOfSize:15];
   
    if (tableView == biaoqiantable_list) {
        
        
        cell = [[getProuductListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ;
         cell.detailTextLabel.font=[UIFont systemFontOfSize:15];
        cell.textLabel.font=[UIFont systemFontOfSize:16];
        cell.textLabel.textColor=qianheicolor;
        cell.textLabel.text =[biaoqianarrrss objectAtIndex:indexPath.row];
        cell.saveAccount=YES;
        cell.xuanzeimage=[[UIImageView alloc] initWithFrame:CGRectMake(ScreenWidth-60-30, 17.5, 18, 18)];
        
        if  ([selectitemNameArray containsObject:[biaoqianarrrss objectAtIndex:indexPath.row]]){
            
            
            cell.xuanzeimage.image=[UIImage imageNamed:@"huiyuan_gou"];
            cell.saveAccount=NO;
            
        }
        
        
        [cell.contentView addSubview:cell.xuanzeimage];
        
        
        
        if (biaoqianarrrss.count !=indexPath.row+1) {
            UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(15, 55-0.35, ScreenWidth-30-45, 0.3)];
            lineLabel1.backgroundColor=qianhuicolor;
            [cell.contentView addSubview:lineLabel1];
            
        }
        
        if (biaoqianarrrss.count ==indexPath.row+1) {
           UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(15, 55-0.35, ScreenWidth-30-45, 0.3)];
            lineLabel1.backgroundColor=qianhuicolor;
            [cell.contentView addSubview:lineLabel1];
            
        }
        
    }
    
    
    //////////////////////////////////22222222222
    if (tableView == table_list) {
         cell.detailTextLabel.font=[UIFont systemFontOfSize:15];
        cell.textLabel.font=[UIFont systemFontOfSize:16];
        cell.textLabel.textColor=qianheicolor;
        if(commdity.content3.length> 0)
            
        {
           
            
            
            if  ([[typeName objectAtIndex:indexPath.row]isEqualToString:commdity.content2]){
                
                
                
                
                if (![commdity.content3 isEqualToString:@"自定义"]) {
                    cell.detailTextLabel.text =commdity.content3;
                    
                    for (int i = 0; i<[[items objectAtIndex:indexPath.row]count]; i++) {
                        
                        if  ([[[[items objectAtIndex:indexPath.row]objectAtIndex:i]objectForKey:@"itemName"] isEqualToString:commdity.content3]){
                            
                            [current replaceObjectAtIndex:indexPath.row withObject:[[items objectAtIndex:indexPath.row]objectAtIndex:i]];
                            
                        }else{
                            
                        }
                        
                    }
                    
                    
                }else{
                    
                    cell.detailTextLabel.text =[NSString stringWithFormat:@"%@~%@",openTimeTextFied.text,closeTimeTextFied.text];
                    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
                    
                    [dic setValue:[NSString stringWithFormat:@"%@",@"Y"]forKey:@"isCustom"];
                    [dic setValue:[NSString stringWithFormat:@"%@",@"Y"] forKey:@"isRange"];
                    [dic setValue:[NSString stringWithFormat:@"%@",@"自定义"] forKey:@"itemName"];
                    [dic setValue:[NSString stringWithFormat:@"%@",@"other"] forKey:@"itemValue"];
                    [dic setValue:openTimeTextFied.text forKey:@"minValue"];
                    [dic setValue:closeTimeTextFied.text forKey:@"maxValue"];
       
                    [current replaceObjectAtIndex:indexPath.row withObject:dic];
       
                    
                }
                
                
                
            }else{
                
                if ([[typeName objectAtIndex:indexPath.row]isEqualToString:@"类别"]) {
                    
                    
                    if ([baioqianshuju isEqualToString:@"youshuju"]) {
                        
                        
                        NSString*  string=[[NSString alloc]init];
                        
                        for(int i = 0; i < selectitemNameArray.count; i++){
                            string = [string stringByAppendingString:[NSString stringWithFormat:@"%@ ",  selectitemNameArray[i]]];
                            
                        }
                        cell.detailTextLabel.text = string;
                    }else{
//                        cell.detailTextLabel.text = [[congzhicurrent objectAtIndex:indexPath.row]objectForKey:@"itemName"];
                    }
                    
                }else{
                    
                    
//                    cell.detailTextLabel.text = [[congzhicurrent objectAtIndex:indexPath.row]objectForKey:@"itemName"];
                }
                
                
            }

            
            
        }else{
            
            
            cell = [[getProuductListCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] ;
            cell.detailTextLabel.font=[UIFont systemFontOfSize:15];
            cell.textLabel.font=[UIFont systemFontOfSize:16];
            cell.textLabel.text = [typeName objectAtIndex:indexPath.row];
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            
            
            
           if ([[typeName objectAtIndex:indexPath.row] isEqualToString:@"类别"]) {
                
                if ([baioqianshuju isEqualToString:@"youshuju"]) {
                    
                    
                    NSString*  string=[[NSString alloc]init];
                    
                    for(int i = 0; i < selectitemNameArray.count; i++){
                        string = [string stringByAppendingString:[NSString stringWithFormat:@"%@ ",  selectitemNameArray[i]]];
                        
                    }
                    cell.detailTextLabel.text = string;
                }else{
                    cell.detailTextLabel.text = [[congzhicurrent objectAtIndex:indexPath.row]objectForKey:@"itemName"];
                }
                
            }else{
                
                
                cell.detailTextLabel.text = [[congzhicurrent objectAtIndex:indexPath.row]objectForKey:@"itemName"];
            }
            
        }
        
        cell.detailTextLabel.textColor=luseColor;
        if (!saveAccount1) {
            if (typeName.count !=indexPath.row+1) {
                UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(15, 55-0.3, ScreenWidth-30-45, 0.3)];
                lineLabel1.backgroundColor=qianhuicolor;
                [cell.contentView addSubview:lineLabel1];
                
            }
            if (typeName.count ==indexPath.row+1) {
                UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(15, 55-0.3, ScreenWidth-30-45, 0.3)];
                lineLabel1.backgroundColor=qianhuicolor;
                [cell.contentView addSubview:lineLabel1];
                saveAccount1=YES;
                
            }}
        
    }
    
    
    return cell;
}






- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (tableView == table_list) {
        return  55;
    }
    if (tableView == biaoqiantable_list) {
        return  55;
    }
    
    return  120;
    
}


#pragma mark - Table view delegate


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    if (tableView == table_list) {
        
        
        
        UITableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath];
        
        if ([cell.textLabel.text isEqualToString:@"类别"]) {
            
            NSMutableArray*arrrss1=[[NSMutableArray alloc]init];
            
            biaoqianarrrss=[[NSMutableArray alloc]init];
            biaoqianitemValue=[[NSMutableArray alloc]init];
            arrrss1=[[items objectAtIndex:indexPath.row] mutableCopy];
            
            for (int i = 0; i<arrrss1.count; i++) {
                [biaoqianarrrss addObject:[[[items objectAtIndex:indexPath.row] objectAtIndex:i] objectForKey:@"itemName"]];
                [biaoqianitemValue addObject:[[[items objectAtIndex:indexPath.row] objectAtIndex:i] objectForKey:@"itemValue"]];
            }
            
            biaoqiantable_list = [[UITableView alloc]initWithFrame:CGRectMake(50, 0, ScreenWidth-50, ScreenHeight) style:UITableViewStylePlain];
            biaoqiantable_list.delegate = self;
            biaoqiantable_list.dataSource = self;
            biaoqiantable_list.rowHeight = 60;
            biaoqiantable_list.separatorStyle=UITableViewCellSeparatorStyleNone;
            [self.window addSubview:biaoqiantable_list];
            
            
            UIView*Header=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth-50, NavHeight)];
            Header.backgroundColor=[UIColor whiteColor];
            biaoqiantable_list.tableHeaderView=Header;
            UILabel*line=[[UILabel alloc]initWithFrame:CGRectMake(0, NavHeight, ScreenWidth-50, 0.35)];
            line.backgroundColor=qianhuicolor;
            [Header addSubview:line];
            
            UILabel*title=[[UILabel alloc]initWithFrame:CGRectMake(0, 20, ScreenWidth-50, NavHeight-20)];
            title.text=@"类别";
            title.textAlignment=NSTextAlignmentCenter;
            [Header addSubview:title];
            
            UIButton*quxiao = [[UIButton alloc] initWithFrame:CGRectMake(5, 20, 50, NavHeight-20)];
            [quxiao setTitle:@"取消" forState:UIControlStateNormal];
            [quxiao setTitleColor:zhonghuiColor forState:UIControlStateNormal];
            quxiao.titleLabel.font=[UIFont systemFontOfSize:16];
            [quxiao addTarget:self action:@selector(biaoqianquxiao:) forControlEvents:UIControlEventTouchUpInside];
            [Header addSubview:quxiao];
            
            UIButton*chongzhi = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-50-60, 20, 50, NavHeight-20)];
            [chongzhi setTitle:@"确认" forState:UIControlStateNormal];
            [chongzhi setTitleColor:luseColor forState:UIControlStateNormal];
            chongzhi.titleLabel.font=[UIFont systemFontOfSize:16];
            [chongzhi addTarget:self action:@selector(biaoqianqueren:) forControlEvents:UIControlEventTouchUpInside];
            [Header addSubview:chongzhi];
            
            
        }else{
            
            
            commdity.content2=typeName[indexPath.row];
            
            [mainScroll removeFromSuperview];
            
            NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
            NSString* Token = [user objectForKey:@"Token"];
            if (Token ==nil) {
                Token=@"dd";
            }
            NSMutableDictionary *param = [NSMutableDictionary new];
            [param setValue:Token forKey:@"Token"];
            
            mainScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(50, 0, ScreenWidth-50, ScreenHeight)];
            mainScroll.delegate = self;
            mainScroll.userInteractionEnabled = YES;
            mainScroll.scrollEnabled = YES;
            mainScroll.backgroundColor=[UIColor whiteColor];
            [self.window addSubview:mainScroll];
            // 手势
            UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBoad1)];
            singleFingerOne.numberOfTouchesRequired = 1; //手指数
            singleFingerOne.numberOfTapsRequired = 1; //tap次数
            singleFingerOne.delegate = self;
            [mainScroll addGestureRecognizer:singleFingerOne];
            UILabel*title=[[UILabel alloc]initWithFrame:CGRectMake(0, 20, ScreenWidth-50, NavHeight-20)];
            title.text=typeName[indexPath.row];
            title.textAlignment=NSTextAlignmentCenter;
            [mainScroll addSubview:title];
            
            UIButton*quxiao1 = [[UIButton alloc] initWithFrame:CGRectMake(5, 20, 50, NavHeight-20)];
            [quxiao1 setTitle:@"取消" forState:UIControlStateNormal];
            [quxiao1 setTitleColor:zhonghuiColor forState:UIControlStateNormal];
            quxiao1.titleLabel.font=[UIFont systemFontOfSize:16];
            [quxiao1 addTarget:self action:@selector(quxiao1:) forControlEvents:UIControlEventTouchUpInside];
            [mainScroll addSubview:quxiao1];
            UILabel*line=[[UILabel alloc]initWithFrame:CGRectMake(0, NavHeight-0.35, ScreenWidth-45, 0.35)];
            line.backgroundColor=qianhuicolor;
            [mainScroll addSubview:line];
            
            
            arrrss=[[NSMutableArray alloc]init];
            
            arrrss=[[items objectAtIndex:indexPath.row] mutableCopy];
            if (arrrss.count>0) {
                
                for (int i = 0; i<arrrss.count; i++) {
                    
                    daogouView = [[sxview alloc]initWithFrame:CGRectMake(15, NavHeight+(55*i), ScreenWidth-45, 55)];
                    
                    daogouView.buttonView.titleLabel.textAlignment=NSTextAlignmentRight;
                    daogouView.buttonView.titleLabel.font=[UIFont systemFontOfSize:16];
                    daogouView.buttonView.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
                    [daogouView.buttonView setTitle: [[[items objectAtIndex:indexPath.row] objectAtIndex:i] objectForKey:@"itemName"] forState:UIControlStateNormal];
                    daogouView.buttonView.backgroundColor=[UIColor whiteColor];
                    daogouView.buttonView.tag=i;
                    [daogouView.buttonView setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
                    [daogouView.buttonView setTitleColor:shenhuicolor forState:0];
                    
                    
                    
                    [mainScroll addSubview:daogouView];
                    
                    if ([[[[items objectAtIndex:indexPath.row] objectAtIndex:i] objectForKey:@"itemName"] isEqualToString:@"自定义"]) {
                        
                        if ([typeName[indexPath.row] isEqualToString:@"时间"]) {
                            
                            [daogouView.buttonView setTitleColor:luseColor forState:0];
                            
                            UIButton*login = [[UIButton alloc] initWithFrame:CGRectMake(0, ScreenHeight-48, ScreenWidth-45, 48)];
                            [login setTitle:@"确认" forState:UIControlStateNormal];
                            [login setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                            login.backgroundColor=luseColor;
                            [login addTarget:self action:@selector(queren:) forControlEvents:UIControlEventTouchUpInside];
                            [mainScroll addSubview:login];
                            
                            
                            
                            
                            _da = [[UIDatePicker alloc] init];
                            [_da addTarget:self action:@selector(dateChanged:) forControlEvents:UIControlEventValueChanged];
                            _da.datePickerMode = UIDatePickerModeDate;
                            _da.backgroundColor=[UIColor whiteColor];
                            
                            
                            openTimeTextFied=[[UITextField alloc]initWithFrame:CGRectMake(50,  daogouView.bottom-55, 110,  55)];
                            openTimeTextFied.borderStyle = UITextBorderStyleNone;
                            openTimeTextFied.font = [UIFont systemFontOfSize: contenfot];
                            openTimeTextFied.textColor=[UIColor blackColor];
                            openTimeTextFied.autocapitalizationType = UITextAutocapitalizationTypeSentences;
                            openTimeTextFied.tag=2;
                            openTimeTextFied.placeholder = @"开始时间"; //默认显示的字
                            openTimeTextFied.delegate = self;
                            openTimeTextFied.text=commdity.opentime;
                            openTimeTextFied.textAlignment=NSTextAlignmentCenter;
                            [openTimeTextFied setUserInteractionEnabled:YES];
                            //                                  openTimeTextFied.clearButtonMode = UITextFieldViewModeWhileEditing;
                            [mainScroll addSubview:openTimeTextFied];
                            
                            UILabel* fuhao=[[UILabel alloc]initWithFrame:CGRectMake(openTimeTextFied.right, daogouView.bottom-55,15,55)];
                            fuhao.text=[NSString stringWithFormat:@"%@", @"～"];
                            fuhao.font=[UIFont systemFontOfSize:contenfot];
                            fuhao.textColor=[UIColor blackColor];
                            [mainScroll addSubview:fuhao];
                            
                            closeTimeTextFied=[[UITextField alloc]initWithFrame:CGRectMake(fuhao.right-5,  daogouView.bottom-55, 110,  55)];
                            closeTimeTextFied.borderStyle = UITextBorderStyleNone;
                            closeTimeTextFied.font = [UIFont systemFontOfSize: contenfot];
                            closeTimeTextFied.textColor=[UIColor blackColor];
                            closeTimeTextFied.autocapitalizationType = UITextAutocapitalizationTypeSentences;
                            closeTimeTextFied.tag=3;
                            closeTimeTextFied.placeholder = @"结束时间"; //默认显示的字
                            closeTimeTextFied.textAlignment=NSTextAlignmentCenter;
                            closeTimeTextFied.text= commdity.closeTime;
                            closeTimeTextFied.delegate = self;
                            [closeTimeTextFied setUserInteractionEnabled:YES];
                            //                                   closeTimeTextFied.clearButtonMode = UITextFieldViewModeWhileEditing;
                            [mainScroll addSubview:closeTimeTextFied];
                            
                            //                                  [_da setAccessibilityLanguage:@"Chinese"];
                            openTimeTextFied.inputView = _da;
                            closeTimeTextFied.inputView = _da;
                            
                        }
                        
                        
                    }else{
                        [daogouView.buttonView addTarget:self action:@selector(xuanzhong:) forControlEvents:UIControlEventTouchUpInside];
                    }
                    
                    if ([[[[items objectAtIndex:indexPath.row] objectAtIndex:i] objectForKey:@"itemName"] isEqualToString:cell.detailTextLabel.text]) {
                        
                       UIImageView*image=[[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth-50-60, 16.5, 18, 18)];
                        image.image=[UIImage imageNamed:@"huiyuan_gou"];
                        
                        [daogouView addSubview:image];
                        
                    }
                }
                
                [mainScroll setContentSize:CGSizeMake(ScreenWidth-45, daogouView.bottom)];
            }
            
            
            
            
        }
    }
    
    if (tableView == _table) {
        
        if ([[NSString stringWithFormat:@"%@",commdity.how]isEqualToString:@"anli"]) {
            
            if ( [commdity.imageUrlFullarr containsObject:imageUrlFull[indexPath.row]]) {
           
            
             [self showAlertMessage:@"此商品已选择"];
            
                
            }else{
                if (commdity.imageUrlFullarr!=nil) {
                    
                    
                    arrrs1 = [commdity.imageUrlFullarr mutableCopy];
                    
                }
                
                [arrrs1 addObject:[NSString stringWithFormat:@"%@",  imageUrlFull[indexPath.row]]];
                
                commdity.imageUrlFullarr=arrrs1;
                
                
                if (commdity.itemIdarr!=nil) {
                    
                    
                    arrrs2 = [commdity.itemIdarr mutableCopy];
                    
                }
                
                [arrrs2 addObject:[NSString stringWithFormat:@"%@",  itemId[indexPath.row]]];
                
                commdity.itemIdarr=arrrs2;
                
                
                [self.navigationController popViewControllerAnimated:YES];

            
               
            
            }
            
            
            
            
            
            
            
            
        }
        if ([[NSString stringWithFormat:@"%@",commdity.how]isEqualToString:@"baojiacp"]) {
//            UITableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath];
//            getProuductListCell *sharecell=(getProuductListCell *)cell;
//            commdity.imagessss=sharecell.imageUrlFull.image;
//            
//            commdity.content=itemType[indexPath.row];
//            commdity.mingchengstring=itemName[indexPath.row];
//            commdity.jiagestring=[NSString stringWithFormat:@"%@",   salePrice[indexPath.row]];
//            
//            addbaojiaViewController *detailViewController = [[addbaojiaViewController alloc] init];
//            [self.navigationController pushViewController:detailViewController animated:YES];
//            
            
            
        }
        
        if ([[NSString stringWithFormat:@"%@",commdity.how]isEqualToString:@"Detail"]) {
//            commdity.itemId=itemId[indexPath.row];
//            commdity.gengxinxiangqing=@"";
//            GetProductDetailViewController *detailViewController = [[GetProductDetailViewController alloc] init];
//            [self.navigationController pushViewController:detailViewController animated:YES];
            
            
//改版后的
            
            ProductDetailViewController *detailViewController = [[ProductDetailViewController alloc] init];
            detailViewController.itemIdStr=itemId[indexPath.row];
            detailViewController.itemCodeStr=itemCode[indexPath.row];
            detailViewController.saveTypeStr=@"PRODUCTDETAIL";
            [self.navigationController pushViewController:detailViewController animated:YES];
            
        }
    }
    
    if (tableView == biaoqiantable_list) {
        
        UITableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath];
        getProuductListCell *sharecell=(getProuductListCell *)cell;
        sharecell.saveAccount=! sharecell.saveAccount;
        
        if (!sharecell.saveAccount) {
            
            [selectitemNameArray addObject:[NSString stringWithFormat:@"%@",[biaoqianarrrss objectAtIndex:indexPath.row]]];
            [selectitemValueArray addObject:[biaoqianitemValue objectAtIndex:indexPath.row]];
            
            [isCustom addObject:@"N"];
            [isRange addObject:@"N"];
            
            
            sharecell.xuanzeimage.image=[UIImage imageNamed:@"huiyuan_gou"];
            
        }
        else{
            UITableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath];
            getProuductListCell *sharecell=(getProuductListCell *)cell;
            
            
            sharecell.xuanzeimage.image=[UIImage imageNamed:@""];
            
            
            if (selectitemNameArray.count>0) {
                
                for (int i=0; i<selectitemNameArray.count; i++) {
                    
                    NSString *codeStr = [selectitemNameArray objectAtIndex:i];
                    if ([codeStr isEqualToString:[NSString stringWithFormat:@"%@",[biaoqianarrrss objectAtIndex:indexPath.row]]] ) {
                        
                        [selectitemNameArray removeObjectAtIndex:i];//从指定索引移除
                        [selectitemValueArray removeObjectAtIndex:i];//从指定索引移除
                        [isCustom removeObjectAtIndex:i];//从指定索引移除
                        [isRange removeObjectAtIndex:i];//从指定索引移除
                    }
                }
            }
        }
        
        
    }
    
}
//确认多标签
-(void)biaoqianqueren:(UIButton*)sender{
    
    biaoqianxuanzhong=[[NSMutableArray alloc]init];
    
    for (int i=0; i<selectitemNameArray.count; i++) {
        NSMutableDictionary *dic = [NSMutableDictionary dictionary];
        NSString *itemName1 = [selectitemNameArray objectAtIndex:i];
        NSString *itemValue1 = [selectitemValueArray objectAtIndex:i];
        NSString *typeName1 = @"N";
        NSString *dataType1 = @"N";;
        
        [dic setValue:[NSString stringWithFormat:@"%@",itemName1]forKey:@"itemName"];
        [dic setValue:[NSString stringWithFormat:@"%@",itemValue1] forKey:@"itemValue"];
        [dic setValue:[NSString stringWithFormat:@"%@",typeName1] forKey:@"isCustom"];
        [dic setValue:[NSString stringWithFormat:@"%@",dataType1] forKey:@"isRange"];
        
        [biaoqianxuanzhong addObject:dic];
    }
    
    
    zhongzhisx=@"youshuju";
    baioqianshuju=@"youshuju";
    
    biaoqiantable_list.frame=CGRectMake(ScreenWidth, 0, ScreenWidth-50, ScreenHeight);
    
    [table_list reloadData];
    
}
//取消多标签为空
-(void)biaoqianquxiao:(UIButton*)sender{
    
    baioqianshuju=@"";
    
    selectitemNameArray=[[NSMutableArray alloc]init];
    selectitemValueArray=[[NSMutableArray alloc]init];
    isCustom=[[NSMutableArray alloc]init];
    isRange=[[NSMutableArray alloc]init];
    
    biaoqiantable_list.frame=CGRectMake(ScreenWidth, 0, ScreenWidth-50, ScreenHeight);
    [table_list reloadData];
    
    
    
}
//取消单个标签
-(void)quxiao1:(UIButton*)sender{
    [openTimeTextFied resignFirstResponder];
    [closeTimeTextFied resignFirstResponder];
    [mainScroll removeFromSuperview];
    
}
-(void)queren:(UIButton*)sender{
    
    if ([ openTimeTextFied.text length] < 1)
    {
        [self showAlertMessage:@"请选择开始时间"];
    }
    else
    {
        
        if ([closeTimeTextFied.text length] <1)
        {
            [self showAlertMessage:@"请选择结束时间"];
        }
        else{
            
            commdity.opentime=openTimeTextFied.text;
            commdity.closeTime=closeTimeTextFied.text;
            [mainScroll removeFromSuperview];
            commdity.content3=@"自定义";
            [table_list reloadData];
            
            
        }}
    
    
}
//xuanzhong选中单个的数据
-(void)xuanzhong:(UIButton*)sender{
    zhongzhisx=@"shuju";
    commdity.content3=sender.titleLabel.text;
    [mainScroll removeFromSuperview];
    [table_list reloadData];
    commdity.opentime=nil;
    commdity.closeTime=nil;
    
    
}

//添加筛选类别
-(void)sxuan:(UIButton*)sender{
    
    
    if(commdity.content3.length> 0){
        
        
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 50, ScreenHeight)];
        view.backgroundColor=[UIColor blackColor];
        view.alpha=0.5;
        [self.window makeKeyAndVisible];
        [self.window addSubview:view];
        
        
        UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBoad)];
        singleFingerOne.numberOfTouchesRequired = 1; //手指数
        singleFingerOne.numberOfTapsRequired = 1; //tap次数
        singleFingerOne.delegate = self;
        [view addGestureRecognizer:singleFingerOne];
        
        table_list.frame=CGRectMake(45, 0, ScreenWidth-45, ScreenHeight);
        [self.window addSubview:table_list];
        UIButton*login = [[UIButton alloc] initWithFrame:CGRectMake(45, ScreenHeight-48, ScreenWidth-45, 48)];
        [login setTitle:@"确认" forState:UIControlStateNormal];
        [login setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        login.backgroundColor=luseColor;
        [login addTarget:self action:@selector(querenleibie:) forControlEvents:UIControlEventTouchUpInside];
        [self.window addSubview:login];
        
        
    }else{
        
        
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 50, ScreenHeight)];
        view.backgroundColor=[UIColor blackColor];
        view.alpha=0.5;
        [self.window makeKeyAndVisible];
        [self.window addSubview:view];
        
        
        UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBoad)];
        singleFingerOne.numberOfTouchesRequired = 1; //手指数
        singleFingerOne.numberOfTapsRequired = 1; //tap次数
        singleFingerOne.delegate = self;
        [view addGestureRecognizer:singleFingerOne];
        
        
         saveAccount1=NO;
        table_list = [[UITableView alloc]initWithFrame:CGRectMake(45, 0, ScreenWidth-45, ScreenHeight) style:UITableViewStylePlain];

        table_list.delegate = self;
        table_list.dataSource = self;
        table_list.rowHeight = 60;
        table_list.separatorStyle=UITableViewCellSeparatorStyleNone;
        [self.window addSubview:table_list];
        
        
        UIView*Header=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth-50, NavHeight)];
        Header.backgroundColor=[UIColor whiteColor];
        table_list.tableHeaderView=Header;
        UILabel*line=[[UILabel alloc]initWithFrame:CGRectMake(0, NavHeight, ScreenWidth-50, 0.35)];
        line.backgroundColor=qianhuicolor;
        [Header addSubview:line];
        
        UILabel*title=[[UILabel alloc]initWithFrame:CGRectMake(0, 20, ScreenWidth-50, NavHeight-20)];
        title.text=@"筛选";
        title.textAlignment=NSTextAlignmentCenter;
        [Header addSubview:title];
        
        UIButton*quxiao = [[UIButton alloc] initWithFrame:CGRectMake(5, 20, 50, NavHeight-20)];
        [quxiao setTitle:@"取消" forState:UIControlStateNormal];
        [quxiao setTitleColor:zhonghuiColor forState:UIControlStateNormal];
        quxiao.titleLabel.font=[UIFont systemFontOfSize:16];
        [quxiao addTarget:self action:@selector(quxiao:) forControlEvents:UIControlEventTouchUpInside];
        [Header addSubview:quxiao];
        
        UIButton*chongzhi = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-50-60, 20, 50, NavHeight-20)];
        [chongzhi setTitle:@"重置" forState:UIControlStateNormal];
        [chongzhi setTitleColor:luseColor forState:UIControlStateNormal];
        chongzhi.titleLabel.font=[UIFont systemFontOfSize:16];
        [chongzhi addTarget:self action:@selector(chongzhi:) forControlEvents:UIControlEventTouchUpInside];
        [Header addSubview:chongzhi];
        
        UIButton*login = [[UIButton alloc] initWithFrame:CGRectMake(45, ScreenHeight-48, ScreenWidth-45, 48)];
        [login setTitle:@"确认" forState:UIControlStateNormal];
        [login setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        login.backgroundColor=luseColor;
        [login addTarget:self action:@selector(querenleibie:) forControlEvents:UIControlEventTouchUpInside];
        [self.window addSubview:login];
    }
}

-(void)chongzhi:(UIButton*)sender{
    searchBeans=nil;
    baioqianshuju=@"";
    [shaixuanBtn setTitleColor:shenhuicolor forState:UIControlStateNormal];
    [sxBtn setImage:[UIImage imageNamed:@"shaixuan"] forState:UIControlStateNormal];
    commdity.content3=@"";
    zhongzhisx=@"";
    current= [congzhicurrent mutableCopy];
    //NSLog(@"----------%@",current);//重置值
    [table_list reloadData];
    
}
//取消筛选
-(void)quxiao:(UIButton*)sender{
    
    [openTimeTextFied resignFirstResponder];
    [closeTimeTextFied resignFirstResponder];
    [self.window makeKeyWindow ];
    self.window.hidden=YES;
    table_list.frame=CGRectMake(ScreenWidth, 0, ScreenWidth-45, ScreenHeight);
    
    
}
//确认筛选
-(void)querenleibie:(UIButton*)sender{
    
    [self.window makeKeyWindow ];
    self.window.hidden=YES;
    table_list.frame=CGRectMake(ScreenWidth, 0, ScreenWidth-45, ScreenHeight);
    
    searchBeans=[NSMutableArray array];
    
    for (int i=0; i<current.count; i++) {
        NSMutableDictionary *dic = [NSMutableDictionary dictionary];
        NSString *typeCode1 = [typeCode objectAtIndex:i];
        NSString *isSingle1 = [isSingle objectAtIndex:i];
        NSString *typeName1 = [typeName objectAtIndex:i];
        NSString *dataType1 = [dataType objectAtIndex:i];
        NSMutableArray* currentarray=[NSMutableArray array];
        [currentarray insertObject:[current objectAtIndex:i] atIndex:0];
        [dic setValue:[NSString stringWithFormat:@"%@",typeCode1]forKey:@"typeCode"];
        [dic setValue:[NSString stringWithFormat:@"%@",isSingle1] forKey:@"isSingle"];
        [dic setValue:[NSString stringWithFormat:@"%@",typeName1] forKey:@"typeName"];
        [dic setValue:[NSString stringWithFormat:@"%@",dataType1] forKey:@"dataType"];
        
        if ([typeName1 isEqualToString:@"类别"]) {
        
            
            if ([baioqianshuju isEqualToString:@"youshuju"]) {
                
                
                [dic setValue:biaoqianxuanzhong forKey:@"items"];
                
                
            }else{
                
                [dic setValue:currentarray forKey:@"items"];
                
            }
            
            
        }else{
            
            [dic setValue:currentarray forKey:@"items"];
            
        }
        
        [searchBeans addObject:dic];
    }
    
  //  NSLog(@"====%@",searchBeans);
    
    
    if ([zhongzhisx isEqualToString:@""]) {
        searchBeans=nil;//重置无数据
    }
    
    [self add];
    
    
}

-(void)closeKeyBoad1{
    [openTimeTextFied resignFirstResponder];
    [closeTimeTextFied resignFirstResponder];
}
-(void)closeKeyBoad{
    [openTimeTextFied resignFirstResponder];
    [closeTimeTextFied resignFirstResponder];
    [self.window makeKeyWindow ];
    self.window.hidden=YES;
    
    table_list.frame=CGRectMake(ScreenWidth, 0, ScreenWidth-45, ScreenHeight);
    saveAccount=YES;
    
    [searchTextField resignFirstResponder];
}


-(void)addProduct:(UIButton*)sender{
        commdity.content=@"";
    commdity.selectTagCodeArray=nil;
    commdity.selectTagNameArray=nil;
        addProductViewController *detailViewController = [[addProductViewController alloc] init];
        [self.navigationController pushViewController:detailViewController animated:YES];
    
    
}

- (void)dateChanged:(id)sender
{
    
    UIDatePicker* picker = (UIDatePicker*)sender;
    NSDateFormatter* df = [[NSDateFormatter alloc] init];
    [df setDateFormat:@"yyyy-MM-dd"];
    
    if ([openTimeTextFied isFirstResponder])
    {
        openTimeTextFied.text = [NSString stringWithFormat:@"%@", [df stringFromDate:picker.date]];
        
        
        
    }else{
        
        closeTimeTextFied.text = [NSString stringWithFormat:@"%@", [df stringFromDate:picker.date]];
    }
    
    
}


- (void)showAlertWait
{
    alt = [[UIAlertView alloc] initWithTitle:@"网络不稳定 ！" message:@"请确认网络" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
    
}

- (void)showAlertMessage:(NSString *)msg
{
    alt = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
}
- (void)hideAlert
{
    if (alt != nil)
    {
        [alt dismissWithClickedButtonIndex:0 animated:YES];
        alt = nil;
    }
}



-(void)jiazai1{
    [jiazai removeFromSuperview];
    
    
}

@end
